import http from '../util/request.js'

export default {
    add: (obj) => {
        return http({
            url: '/api/admin',
            method: 'post',
            data: obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
    edit: (obj) => {
        return http({
            url: '/api/admin',
            method: 'put',
            data: obj,
            headers: {
                //定义将数据以json的形式传入后台(java)
                'Content-Type': 'application/json'
            }
        });
    },
    del: (id) => {
        return http({
            url: '/api/admin/' + id,
            method: 'delete',
        });
    },
    page: (obj) => {
        return http({
            url: '/api/admin/page',
            method: 'get',
            params: obj
        });
    },
    cleanupImages: () => {
        return http({
            url: '/api/image/cleanup',
            method: 'post'
        });
    }
}
    // 轮播图API
    export const carouselApi = {
        // 获取轮播图列表
        getCarouselList: () => {
            return http({
                url: '/api/carousel/list',
                method: 'get'
            });
        },

        // 添加轮播图
        addCarousel: (obj) => {
            return http({
                url: '/api/carousel',
                method: 'post',
                data: obj,
                headers: {
                    'Content-Type': 'application/json'
                }
            });
        },

        // 删除轮播图
        deleteCarousel: (id) => {
            return http({
                url: '/api/carousel/' + id,
                method: 'delete'
            });
        }
    }

